<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>新品有戏后台管理</title>
    <link href="__CSS__/boot.css" rel="stylesheet">
    <link href="__STATIC__/layui/css/layui.css" rel="stylesheet">
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/layer/layer.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
</head>
<body>
<label style="display: none" id="id">{$id}</label>
<label style="display: none" id="bid">{$bid}</label>
<div style="margin-left: 90px;margin-top: 50px">
    <button type="button" class="layui-btn" id="uploads">
        <i class="layui-icon">&#xe67c;</i>上传视频
    </button>
</div>
</body>
<script>
    layui.use('upload', function(){
        var id = $("#id").html();
        var bid = $("#bid").html();
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#uploads' //绑定元素
            ,accept:'video'
            ,data:{'id':id,'bid':bid}
            ,url: "{:url('index/content/videoUpload')}?id="+id+"&bid="+bid //上传接口
            ,done: function(res){
                if(res.success){
                    layer.alert(res.success,{bnt:['确定','取消']},
                        function () {
                            //获取窗口索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭弹出的子页面窗口
                            parent.layer.close(index);
                            window.parent.location.reload();
                        },function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                            window.parent.location.reload();
                        }
                    );
                }
                if(res.error){
                    layer.alert(res.error);
                }
            }
        });
    });
</script>
</html>